package com.ohc.leetcode.哈希表;

/**
 * 2022年5月30日14:49:02
 */
public class 快乐数202 {

    public static boolean isHappy(int n) {
        int mo = 0;
        int sum = 0;

        while (n % 10 != 0) {
            mo = n % 10;
            n = n / 10;
            sum += mo * mo;
            if (n % 10 == 0) {

                if (sum == 1) {
                    return true;
                }
                sum = 0;

            }
        }


        return false;
    }

    public static void main(String[] args) {
        boolean happy = isHappy(19);
        System.out.println("happy = " + happy);
    }
}
